package org.soderiakelvy.model.services.testCase;

import static org.junit.Assert.*;

import java.util.List;

import junit.framework.Assert;

import org.junit.BeforeClass;
import org.junit.Test;
import org.soderiakelvy.model.domain.ProductoVO;
import org.soderiakelvy.model.domain.RepartoVO;
import org.soderiakelvy.model.domain.SujetoVO;
import org.soderiakelvy.model.domain.TipoProductoVO;
import org.soderiakelvy.model.service.ProductoServicio;
import org.soderiakelvy.model.service.RepartoServicio;
import org.soderiakelvy.model.service.SujetoServicio;
import org.soderiakelvy.model.service.imp.ProductoServicioImp;
import org.soderiakelvy.model.service.imp.RepartoServicioImp;
import org.soderiakelvy.model.service.imp.SujetoServicioImpl;
import org.soderiakelvy.model.util.ConstantModel;

public class TestReparto {
	//@BeforeClass

	
	@Test
	public void testRepartoCrud(){
		
		RepartoServicio rs = new RepartoServicioImp();
		RepartoVO rVO = new RepartoVO();
		
		
		
		rVO.setNombre("testNombre");
		rVO.setEstado("----");
		rVO.setDescripcion("testDescripcion");	
		
		//----------- TEST  ALTA DE UN REPARTO ------------------
		Assert.assertEquals(ConstantModel.SUCCESS,rs.insertReparto(rVO));
		System.out.println("TEST ALTA OK");
		//-----------------------------------------------------------------------------
		
		//----------- TEST UPDATE REPARTO -----------------------------
		rVO.setEstado("testEstado");
		Assert.assertEquals(ConstantModel.SUCCESS,rs.updateReparto(rVO));
		System.out.println("TEST UPDATE OK");
		//-----------------------------------------------------------------------------
		
		//----------- TEST OBTENER UN REPARTO POR SU ID ------------------
		Assert.assertNotNull(rs.getRepartoById( rVO.getRepartoId()  ));
		System.out.println("TEST OBTENER UN  PRODUCTO OK");
		//-----------------------------------------------------------------------------
				
		//----------- TEST ELIMINACION DE UN REPARTO ------------------------
		Assert.assertEquals(ConstantModel.SUCCESS,rs.deleteReparto(rVO));
		System.out.println("TEST ELIMINAR OK");
		//-----------------------------------------------------------------------------

		//----------- TEST  GETALL REPARTO ------------------------
		List<RepartoVO> repartos1 = rs.getRepartos();
		Assert.assertEquals(repartos1.size(), 1);
		for(RepartoVO r : repartos1){
			System.out.println(r);
		}
		System.out.println("TEST GETALL OK");
		//-----------------------------------------------------------------------------
	}
}
